<include file="public@header"/>
</head>
<body>
<div class="wrap">
    <h1>{$type==1?'添加子女':($type==2?'添加配偶':'')}</h1>
    <form class="form" id="form" method="post" action="">
        <input type="hidden" name="type" value="{$type}">
        <input type="hidden" name="id" value="{isset($id)?$id:''}">
        <input type="hidden" name="target_id" value="{isset($target_id)?$target_id:''}">
        <div class="form-group">
            <label for="name">名</label>
            <input type="text" class="form-control" id="name" name="name" maxlength="30" value="{:isset($data)?$data.name:''}" placeholder="本氏族的成员，无需填姓">
        </div>
        <if condition="$type==1">
        <div class="form-group">
            <label for="styleName">字</label>
            <input type="text" class="form-control" id="styleName" name="style_name" maxlength="30" value="{:isset($data)?$data.style_name:''}" placeholder="字，可为空">
        </div>
        <div class="form-group">
            <label>性别</label>
            <div class="radio">
                <label>
                    <input type="radio" name="gender" id="gender0" value="0" <if condition="!isset($data) || (isset($data) && $data['gender']==0)">checked</if>>
                    未知
                </label>
            </div>
            <div class="radio">
                <label>
                    <input type="radio" name="gender" id="gender1" value="1" <if condition="isset($data) && $data['gender']==1">checked</if>>
                    男
                </label>
            </div>
            <div class="radio">
                <label>
                    <input type="radio" name="gender" id="gender1" value="2" <if condition="isset($data) && $data['gender']==2">checked</if>>
                    女
                </label>
            </div>
        </div>
            <!--添加子女 -->
            <div class="form-group">
                <label for="clan">房族</label>
                <select name="clan_id" id="clan" class="form-control">
                    <option value="">请选择...</option>
                    <option value="0" <if condition="isset($data) && $data.clan_id==0">selected="selected"</if>>无</option>
                    <foreach name="clan_tree" item="vo">
                        <option value="{$vo.id}" <if condition="isset($data) && $data.clan_id==$vo.id">selected="selected"</if>><for start="0" end="$vo.level">|-</for>{$vo.name}</option>
                    </foreach>
                </select>
            </div>
            <div class="form-group">
                <label for="ranking">家庭排行</label>
                <input type="number" class="form-control" id="ranking" name="ranking" maxlength="30" value="{:isset($data)?$data.ranking:''}" placeholder="家庭排行">
            </div>
        </if>
        <div class="form-group">
            <label for="description">成员介绍</label>
            <textarea class="form-control" id="description" row="3" name="description">{:isset($data)?$data.description:''}</textarea>
        </div>
        <button class="btn btn-primary" type="submit">确定</button>
    </form>
</div>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
<script type="application/javascript" language="javascript">
    $().ready(function() {
        $("#form").validate({
            rules:
            {
                name: "required",
                gender:"required"<if condition="$type==1">,
                clan_id:{
                    required:true
                },
                ranking:{
                    required:true,
                    digits:true,
                    min:1
                }
                </if>
            },
            messages:
            {
                name: "请输入名字",
                gender:"请选择性别"<if condition="$type==1">,
                clan_id:{
                    required:"请选择房族"

                },
                ranking:{
                    required:"请选择输入家庭排行",
                    digits:"必须是正整数",
                    min:"最小值为1"
                }
                </if>
            }
        });
    });
</script>
</body>
</html>